package com.cxs.mapper;

import com.cxs.pojo.Menu;
import com.cxs.pojo.User;
import com.cxs.pojo.UserExample;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;

public interface UserMapper {
    long countByExample(UserExample example);

    int deleteByExample(UserExample example);

    int deleteByPrimaryKey(Integer userId);

    int insert(User record);

    int insertSelective(User record);

    List<User> selectByExample(UserExample example);

    User selectByPrimaryKey(Integer userId);

    int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);

    int updateByExample(@Param("record") User record, @Param("example") UserExample example);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    // 根据用户查权限菜单
    List<Menu> selectMenuByUserId(@Param("userId") Integer userId);

    // 清空用户原角色
    @Delete("delete from sys_role_user where uid = #{userId}")
    Integer clearRole(@Param("userId")Integer userid);

    /**
     * 给用于授予角色
     * @param userid
     * @param ids
     * @return
     */
    Integer saveRoleToUser(@Param("userId") Integer userid, @Param("ids") List<Integer> ids);
}